{% extends 'base.html' %}

{% block style %}
    <style>
        img{
            width: 100%;
            height:100%;
        }
        .container {
            border: 1px solid black;
            background-color: white;
        }
        .jumbotron{
            padding: 0 0 0 0;
            background-color: white;
            margin-bottom: 0;
        }
        .container .jumbotron, .container-fluid .jumbotron {
            padding-right: 0;
            padding-left: 0;
        }
        @media (min-width: 768px) {
          .container {
            max-width: 540px;
          }
        }
        .pull-right {
            width: 100%;
        }
        .pull-right li {
            width: 33%;
            height: 100%;
            text-align: center;
            font-size: 20px;
        }
        .nav-pills > li+li{
            margin-left: 0;
        }
        .pull-right li:first-child{
            border-right: 1px solid lightgrey;
            border-bottom: 5px solid #d7736b;
        }
        .pull-right li:nth-child(2){
            border-right: 1px solid lightgrey;
            border-bottom: 5px solid #4587c0;
            border-right: 0;
        }
        .pull-right li:last-child{
            border-left: 1px solid lightgrey;
            border-bottom: 5px solid #685c89;
        }
        .titles-s {
            font-size: 24px;
            padding-top: 5px;
            font-weight: 700;
            color: #888888;
        }
        .titles-l {
            color: #8e9899;
            font-size: 18px;
        }
        .header{
            height: 85px;
            padding-bottom: 10px;
            border-bottom: 0;
        }
        @media screen and (min-width: 768px) {
          /* Remove the padding we set earlier */
          .header,
          .marketing,
          .footer {
            padding-right: 0;
            padding-left: 0;
          }
          .header {
            margin-bottom: 20px;
          }
          .jumbotron {
            border-bottom: 0;
          }
        }

        .tj_y{
            text-align: center;
            font-size: 24px;
            color: #666766;
            padding-bottom: 4px;
        }
        .common {
            text-align: center;
            padding-top: 10px;
            width: 90%;
            margin: 0 auto;
        }
        .row p:nth-child(3){
            padding-top: 0;
        }
        .row p:nth-child(11){
            font-size: 18px;
            color: #666667;
        }
        .from_main{
            width: 100%;
            margin-top: 20px;
            color: #666667;
        }
        .items_common{
            margin: 10px auto;
        }
    </style>
{% endblock %}

{% block content %}
    <div class="container">
      <div class="header">
          <ul class="nav nav-pills pull-right">
            <li><p class="titles-s">0</p><p class="titles-l">You Entries</p></li><!---->
            <li><p class="titles-s">{{ people_number }}</p><p class="titles-l">Totals Entries</p></li><!---->
            <li id="timer">
                <p class="titles-s" id="day-time"></p>
                <p class="titles-l" id="time-list"></p>
            </li>
          </ul>
      </div>
      <div class="tj_y">
          Join the Raptor baby white list
      </div>
      <div class="jumbotron">
          <img src="/static/images/banner.png" alt="banner.png">
      </div>
      <div class="row">
        <p class="common">$BaByRaptorsBaBy(RTB)</p>
        <p class="common">
            The latest twitter-engine is raptors, which can be found on twitter
        </p>
        <p class="common">
            We will use our platform to randomly select 100 entries for the winning white list
        </p>

        <p class="common">
            If you are not selected in the first round, you have to wait for our contract to come into effect
        </p>

        <p class="common">Enter your enail address to check whether you are the lucky one</p>
        <p class="common">⏰  The competition will end at: 0 a.m. on July 19 UTC ⏰</p>
        <p class="common"><b>IMPORTANT</b> - It's paramount you use a working email. Please go to your inbox and confirm our whitelist notification email.</p>
        <p class="common">---------------------------------------------------------------</p>
        <p class="common">Please Input  your email To Search</p>
      </div>

            <div class="from_main">
          <form class="form-inline" id="form_d">
              <div class="items_common">
                  <div class="form-group">
                    <label for="email" style="margin-right: 100px">Email:</label>
                    <input type="email" class="form-control" id="email" placeholder="jane.doe@example.com" alt="请填写该字段" style="width: auto">
                  </div>
              </div>
              <hr>
              <div style="text-align: center;font-size: 20px; font-weight: 700; color: red" id="search_result">
              </div>
              <hr>
              <div style="margin: 0 auto; text-align: center; padding-bottom: 10px">
                  <button type="button" class="btn btn-primary btn-block" onclick="doSearch()">Search</button>
              </div>
        </form>
      </div>


      <footer class="footer">
        <p>&copy; 2016 Company, Inc.</p>
      </footer>

    </div> <!-- /container -->
{% endblock %}


{% block js %}
    <script>
        function doSearch(){
            $.ajax({
                method: 'get',
                url: "/search/?email=" + $("#email").val(),
                success: function (resp){
                    if (resp['code'] === 200){
                        location.href = '/k_page/?user_id=' + resp['user_id']
                    }else{
                        $("#search_result").text(resp['msg'])
                    }
                }
            })
        }

                    function getTime(val) {
                var d,h,m,s,timeText;
                var oP = $('#time-list');
                setInterval(function(){
                    val--;
                    d = parseInt(val /(24*3600));
                    h = parseInt(val/60/60%24);
                    m = parseInt(val/60%60);
                    s = parseInt(val%60);
                    s = s < 10 ? "0" + s : s ;
                    timeText = h +"时" + m + "分" + s + "秒";
                    oP.text(timeText)
                    $('#day-time').text(d + "天");
                },1000)
            }

            if({{ left_time }} > 0 ) {
                getTime({{ left_time }})
            } else {
                $('#day-time').text("0天");
                $('#time-list').text("00时00分00秒");
            }
    </script>
{% endblock %}